package com.ruoyi.project.treat.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.treat.domain.*;
import com.ruoyi.project.treat.service.ITreatRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/treat/register")
public class TreatRegisterController extends BaseController {
    @Autowired
    private ITreatRegisterService registerService;

    /**
     * 获取挂号列表
     */
    @PreAuthorize("@ss.hasPermi('treat:register:list')")
    @GetMapping("/list")
    public TableDataInfo list(TreatRegister register, SystemTregistraFee tregistraFee, SystemUser user, SystemDept dept, TreatPatient patient)
    {
        user.setSystemDept(dept);
        register.setSystemTregistraFee(tregistraFee);
        register.setSystemUser(user);
        register.setTreatPatient(patient);
        System.out.println("*******" + register);
        startPage();
        List<TreatRegister> list = registerService.selectRegisterList(register);
        return getDataTable(list);
    }

    /**
     * 根据挂号状态获取挂号详细信息
     */
    @PreAuthorize("@ss.hasPermi('treat:patient:query')")
    @GetMapping(value = "/{registerStatus}")
    public AjaxResult getInfo(@PathVariable String registerStatus)
    {
        return AjaxResult.success(registerService.selectRehisterByRegisterStatus(registerStatus));
    }
}
